<?php
/**
 * Created by PhpStorm.
 * User: admin-chen
 * Date: 15-10-17
 * Time: 上午11:39
 */
$dirName = $argv[1];


function tree($directory)
{
    $mydir = dir($directory);

    while($file = $mydir->read())
    {
        if($file == "." || $file == ".."){
            continue;
        }
        if(is_dir("$directory/$file"))
        {
            $oldName = basename($file,'.po');
            $poFileName = "$directory/$file";
            tree($poFileName);
        }
        else{
            $poFileName = $file;
            $oldName = basename($file,'.po');
        }

        $moName = $oldName.'.mo';

        system("msgfmt -o  {$moName} {$directory}/{$poFileName}",$a);

        echo $moName."\n";

    }

    $mydir->close();
}
//开始运行

tree($dirName);
